<template>
	<view>
		<cu-custom bgColor="bg-gradual-blue" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">我的订单</block>
		</cu-custom>

		<view class="cu-list menu-avatar">
			<navigator class="cu-item" v-for="(item,index) in orderList" :key="item.id" :url="'../orderDetail/orderDetail?id='+item.id"
			 open-type="navigate">
				<view class="cu-avatar radius lg" :style="'background-image:url('+imageSrc+item.items[0].image+');'"></view>
				<view class="content">
					<view class="text-gray">
						<view class="text-cut text-sm">收货地址：{{ item.province+item.address+item.district }}</view>
					</view>
					<view class="text-gray text-sm flex">
						<view class="text-cut">订单编号：{{ item.id }}</view>
					</view>
				</view>
				<view class="action">
					<view class="text-red text-xs">￥{{ item.orderMoney }}</view>
					<view class="cu-tag  bg-green sm" v-if="item.status">已支付</view>
					<view class="cu-tag  bg-red sm" v-else>未支付</view>
					<view class="text-blue text-xs">{{ item.shippingUser }}</view>
				</view>
			</navigator>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				orderList: [],
				imageSrc: 'http://123.57.7.108:81/',
				address:''
			}
		},
		onLoad() {
			this.init();
		},
		onPullDownRefresh() {
			this.init();
			uni.stopPullDownRefresh();
		},
		methods: {
			init() {
				this.$storage.getStorage('user')
					.then(res => {
						return this.$api.api_getAllOrder({
							customerId: res.data.id
						})
					})
					.then(res => {
						this.orderList = res.data.data;
						this.address =res.data.address;
					})
					.catch(err => {
						console.log(err)
					})
			}
		}
	}
</script>

<style>

</style>
